package org.coopac.controller.simulador;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name="reportePrestamo")
@SessionScoped
public class ReportePrestamo implements Serializable{
	
	private final static String[] manufacturers;
	private int interes;
	
	private List<ManufacturerSale> sales;

		static {
			manufacturers = new String[10];
			manufacturers[0] = "Enero";
			manufacturers[1] = "Febrero";
			manufacturers[2] = "Marzo";
			manufacturers[3] = "Abril";
			manufacturers[4] = "Mayo";
			manufacturers[5] = "Junio";
			manufacturers[6] = "Julio";
			manufacturers[7] = "Agosto";
			manufacturers[8] = "Setiembre";
			manufacturers[9] = "Octubre";
		}


		public ReportePrestamo() {
			populateRandomSales();
		}

		int ii = 0;
	    private int getRandomSale() {
	    	interes = (int) (1000-(100*ii)); 
	    	ii++;
		  return interes;
		}
	    private int getRandomSale1() {
	    	  return (int) (1000/10);
		}
	    private int getRandomProfit() {
	    	 return (int) (1000*(0.025));
		}
	    
	    private int getRandomProfit1() {
	    	 return (int) ((1000/10)+(1000*(0.025)));
		}

	    public List<ManufacturerSale> getSales() {
	        return sales;
	    }

	    private void populateRandomSales() {
		    sales = new ArrayList<ManufacturerSale>();
		
		    for(int i = 0; i < 10; i++) {
		        sales.add(new ManufacturerSale(manufacturers[i], getRandomSale(), getRandomSale1(), getRandomProfit(), getRandomProfit1()));
		    }
		}

	    public int getLastYearTotal() {
	        int total = 0;

	        for(ManufacturerSale sale : getSales()) {
	            total += sale.getLastYearSale();
	        }

	        return total;
	    }

	    public int getThisYearTotal() {
	        int total = 0;

	        for(ManufacturerSale sale : getSales()) {
	            total += sale.getThisYearSale();
	        }

	        return total;
	    }
	    
	    
	    
	    
	    
	    
	    
	    
	}